package controller;


import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import databean.Email;

import model.EmailDAO;
import model.Model;


public class ConversationDetailsAction extends Action {
	private EmailDAO emailDAO;
	
	public ConversationDetailsAction(Model model) {
		this.emailDAO = model.getEmailDAO();
	}

	public String getName() { return "conversation-details.do"; }
    
    public String perform(HttpServletRequest request,HttpServletResponse response) {
        
    	List<String> errors = new ArrayList<String>();
    	String str = request.getParameter("messageId");
    	long longMsgId = Long.parseLong(str);
    	
    	
		try {

	    	Email newEmail;
			newEmail = emailDAO.getEmail(longMsgId);
			
	        request.setAttribute("email",newEmail);
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			errors.add(e.getMessage());
	    	return "conversation-details.jsp";
		}
		
    	
    	
    	return "conversation-details.jsp";
    }
}
